<template>
	<view class="info-wrap">
		<view class="user-info">
			<image :src="userInfo.avatarUrl"></image>
			<view>{{ userInfo.nickName }}</view>
		</view>
		<view class="panel-wrap">
			<view class="panel-item">
				<view class="item-content">
					<view>
						<text>8</text>
						<text>收藏的店铺</text>
					</view>
					<view>
						<text>14</text>
						<text>收藏的商品</text>
					</view>
					<view>
						<text>18</text>
						<text>关注的商品</text>
					</view>
					<view>
						<text>84</text>
						<text>足迹</text>
					</view>
				</view>
			</view>
			<view class="panel-item">
				<view class="title">我的订单</view>
				<view class="item-content">
					<view>
						<image src="../../static/my-icons/icon1.png"></image>
						<text>待付款</text>
					</view>
					<view>
						<image src="../../static/my-icons/icon2.png"></image>
						<text>待收货</text>
					</view>
					<view>
						<image src="../../static/my-icons/icon3.png"></image>
						<text>退款/退货</text>
					</view>
					<view>
						<image src="../../static/my-icons/icon4.png"></image>
						<text>全部订单</text>
					</view>
				</view>
			</view>
			<view class="panel-item">
				<view class="cell">
					<text>收货地址</text>
					<uni-icons type="right"></uni-icons>
				</view>
				<view class="cell">
					<text>联系客服</text>
					<uni-icons type="right"></uni-icons>
				</view>
				<view @click="logout" class="cell">
					<text>退出登录</text>
					<uni-icons type="right"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	name: 'my-userinfo',
	computed: {
		...mapState('m_user', ['userInfo'])
	},
	data() {
		return {};
	},
	methods: {
		async logout() {
			const res = await uni.showModal({
				title: '是否退出',
				content: '你确定要退出吗？'
			});
			if (res[1].confirm) {
				// 调用vuex方法
				this.$store.commit('m_user/logout');
				uni.$showToast('已成功退出');
			}
		}
	}
};
</script>

<style lang="scss">
.info-wrap {
	background-color: #f4f4f4;
	height: 100vh;
	.user-info {
		height: 180px;
		background-color: #c00000;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #fff;
		font-weight: 700;
		image {
			width: 80px;
			height: 80px;
			margin-bottom: 10px;
			border-radius: 50%;
		}
	}
	.panel-wrap {
		height: 360px;
		width: 700rpx;
		position: absolute;
		top: 160px;
		left: 25rpx;
		.panel-item {
			background-color: #fff;
			margin-bottom: 10px;
			padding: 10px;
			font-size: 14px;
			&:first-child {
				border-radius: 10px 10px 0 0;
			}
			&:last-child {
				border-radius: 0 0 10px 10px;
			}
			.cell {
				display: flex;
				justify-content: space-between;
				padding: 10px 0;
			}
			.title {
				padding: 10px 0;
				border-bottom: 1rpx solid #ddd;
				margin-bottom: 10px;
			}
			.item-content {
				display: flex;
				justify-content: space-between;
				& > view {
					display: flex;
					flex-direction: column;
					align-items: center;
					image {
						width: 35px;
						height: 35px;
					}
				}
			}
		}
	}
}
</style>
